﻿using ICSharpCode.WinFormsUI.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DevelopAssistant.Core.ToolBox
{
    public partial class SnippetPad : ICSharpCode.WinFormsUI.Docking.DockContent, IDocumentContent
    {
        public SnippetPad()
        {
            InitializeComponent();
        }

        public SnippetPad(Form mainForm)
            : this()
        {

        }

        private string DocumentTypeParse(string formats)
        {
            string result = "None";
            switch (formats)
            {
                case ".cs":
                    result = "Csharp";
                    break;
                case ".js":
                    result = "Javascript";
                    break;
                case ".json":
                    result = "Json";
                    break;
                case ".sql":
                    result = "TSql";
                    break;
                case ".py":
                    result = "Python";
                    break;
                case ".xml":
                    result = "XML";
                    break;
                case ".config":
                    result = "Configuation";
                    break;
            }
            return result;
        }

        public void LoadSnippet(string text,string formats)
        {            
            this.textBoxControl1.DocumentType = (DocumentType)Enum.Parse(typeof(DocumentType), DocumentTypeParse(formats));
            this.textBoxControl1.Text = text;
        }

        public void FindAndReplace(FindAndReplaceRequest request)
        {

        }

        protected override void OnClosing(CancelEventArgs e)
        {
            this.textBoxControl1.ReleaseDispose();
            base.OnClosing(e);
        }

    }
}
